package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 用户填写的制证信息
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateUserCertificateStatusEnum", description = "证件状态:#{AUTH:待审核;CHECK_FAIL:审核失败;SUBMIT:待提交;PAY:待付款;NO_PRINT:待制证;PRINT:已制证;DRAW:已领取;END:结束;-枚举")
public enum CertificateUserCertificateStatusEnum implements BaseEnum {

    /**
     * AUTH="待审核"
     */
    AUTH("待审核"),
    /**
     * CHECK_FAIL="审核失败"
     */
    CHECK_FAIL("审核失败"),
    /**
     * SUBMIT="待提交"
     */
    SUBMIT("待提交"),
    /**
     * PAY="待付款"
     */
    PAY("待付款"),
    /**
     * NO_PRINT="待制证"
     */
    NO_PRINT("待制证"),
    /**
     * PRINT="已制证"
     */
    PRINT("已制证"),
    /**
     * DRAW="已领取"
     */
    DRAW("已领取"),
    /**
     * END="结束"
     */
    END("结束"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateUserCertificateStatusEnum match(String val, CertificateUserCertificateStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateUserCertificateStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateUserCertificateStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "AUTH,CHECK_FAIL,SUBMIT,PAY,NO_PRINT,PRINT,DRAW,END", example = "AUTH")
    public String getCode() {
        return this.name();
    }

}
